package _interview150;

import _object.TreeNode;

/**
 * 112. 路径总和
 */
public class No112 {
    public boolean hasPathSum(TreeNode root, int targetSum) {
        if (root == null) return false;
        else if (root.left == null && root.right == null) return root.val == targetSum;
        else return hasPathSum(root.left, targetSum - root.val)
                    || hasPathSum(root.right, targetSum - root.val);
    }
}
